package com.jcc.springcloud.service.impl;

import com.jcc.springcloud.common.utils.MD5Utils;
import com.jcc.springcloud.dao.LoginDao;
import com.jcc.springcloud.service.LoginService;
import com.jcc.springcloud.user.UserDo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class LoginServiceImpl implements LoginService {
    @Resource
    private LoginDao loginDao;

    @Override
    /*查询用户是否存在*/
    public UserDo findUserByName(UserDo userDo) {
        UserDo userByName = loginDao.findUserByName(userDo);
        return userByName;
    }

    @Override
    /*查询用户名和密码是否匹配*/
    public UserDo findUserByPwd(UserDo userDo) {
        String md5Pwd = MD5Utils.md5Encrypt32Lower(userDo.getPwdMd5().toString());
        userDo.setPwdMd5(md5Pwd);
        UserDo userByPwd = loginDao.findUserByPwd(userDo);
        return userByPwd;
    }
}
